<template>
  <div class="accordion">
    <slot>
      <div class="item__box" v-for="(item, i) of list" :key="i">
        <div class="item__content" :class="[`item__content${i}`, { 'item__content-active': activeIndex === i }]">
          <div class="item__content__detail">
            <slot :name="`item__content${i}`"> </slot>
          </div>
        </div>
        <div class="item__title" :class="[`item__title${i}`, { 'item__title-active': activeIndex === i }]">
          <div class="item__title__detail" @click="() => tabChange(i)">
            <slot :name="`item__title${i}`">
              <img v-if="!!item.icon" :src="activeIndex === i ? getImageUrl(item.activeIcon) : getImageUrl(item.icon)" alt="" />
              <div class="item__title__detail__text">{{ item.title }}</div>
            </slot>
          </div>
        </div>
      </div>
    </slot>
  </div>
</template>
<script setup>
import { reactive, toRefs, onBeforeMount, onMounted, ref } from 'vue'
// import { getImageUrl } from '@/untils/index'


defineProps({
  list: {
    type: Array,
    default: () => []
  }
})

const getImageUrl = (icon) => {
  return `@/assets/logo.png`;
}

const activeIndex = ref(0)

const tabChange = (index) => {
  activeIndex.value = index
}
</script>
<style scoped>
.accordion {
  position: relative;
  width: 1181px;
  height: 512px;
  display: flex;
  color: #fff;
  /* background: url('@/assets/logo.png'); */
  background: #2269d2;
  overflow: hidden;
}
.item__box {
  position: relative;
  display: flex;
  overflow: hidden;
  margin-left: 4px;
}
.item__content {
  flex-shrink: 0;
  width: 0;
  left: 1000px;
  overflow: hidden;
  transition: all 0.5s ease;
}
.item__title {
  width: 110px;
  flex-shrink: 0;
  background: #00398e;
}
.item__content__detail {
  width: 842px;
  height: 512px;
  opacity: 0;
  transition: opacity 0.5s ease;
}
.item__content-active {
  width: 842px;
  left: 0;
}

.item__content-active .item__content__detail {
  opacity: 1;
}

.item__title__detail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 512px;
  cursor: pointer;
}

.item__title__detail__text {
  writing-mode: vertical-lr;
  height: 160px;
  font-size: 28px;
  font-family: PingFangSC-Semibold, PingFang SC;
  font-weight: 600;
  color: #ffffff;
  line-height: 40px;
  letter-spacing: 8px;
}

.item__title-active {
  background: linear-gradient(180deg, #ffbb1a 0%, #f57c00 100%);
}

@keyframes moveInRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}
</style>

